package com.hou.controller;

import com.hou.pojo.Rule;
import com.hou.pojo.RuleVo;
import com.hou.pojo.Vip;
import com.hou.service.DroolService;
import com.hou.vo.CaseVip;
import com.hzk.vo.RespBean;
import com.hzk.vo.RespBeanEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auoter:jackh
 */
@RestController
@Controller
@RequestMapping("/hou")
public class rule {
    @Autowired
    DroolService droolService;

    /**
     * 修改规则接口
     * @param rule
     */
    @RequestMapping("/rule/update")
    public RespBean update(@CaseVip Vip vip, Rule rule) {
        if (vip==null){
            return RespBean.error(RespBeanEnum.NULL_USER_ERROR);
        }
        droolService.updateBymap(rule);
        return RespBean.success();
    }
    @RequestMapping("/rule/select")
    public RespBean select(@CaseVip Vip vip) {
        if (vip==null){
            return RespBean.error(RespBeanEnum.NULL_USER_ERROR);
        }
        List<Rule> select = droolService.select();
        return RespBean.success(select);
    }
    @RequestMapping("/rule/show")
    public RespBean select(@CaseVip Vip vip,Long id) {
        if (vip==null){
            return RespBean.error(RespBeanEnum.NULL_USER_ERROR);
        }
        Rule byId = droolService.getById(id);
        return RespBean.success(byId);
    }
}
